package com.woniuxy.web;



import com.woniuxy.service.impl.Impl;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;


public class MaFanServlet implements Controller {
    @Override
    public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
        ApplicationContext applicationContext = new ClassPathXmlApplicationContext("applicationContext.xml");
        Impl impl = applicationContext.getBean("impl", Impl.class);
        Map one = impl.findOne(1);
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("msg",one.keySet());
        modelAndView.setViewName("/index.jsp");
        return modelAndView;
    }
    @Test
    public void ceshi(){
        ApplicationContext applicationContext = new ClassPathXmlApplicationContext("applicationContext.xml");
        Impl impl = applicationContext.getBean("impl", Impl.class);
        Map one = impl.findOne(1);
        System.out.println(one);
    }
}
